export const DOMUtils = {
    getElement(selector) {
        const element = $(selector);
        return element.length ? element : null;
    },

    getValue(selector) {
        const element = this.getElement(selector);
        return element ? element.val() : '';
    },

    setValue(selector, value) {
        const element = this.getElement(selector);
        if (element) element.val(value);
    },

    setProperty(selector, property, value) {
        const element = this.getElement(selector);
        if (element) element.prop(property, value);
    },

    isEmpty(selector) {
        const element = this.getElement(selector);
        return element ? element.is(':empty') : true;
    },

    show(selector) {
        const element = this.getElement(selector);
        if (element) element.show();
    },

    hide(selector) {
        const element = this.getElement(selector);
        if (element) element.hide();
    },

    empty(selector) {
        const element = this.getElement(selector);
        if (element) element.empty();
    },

    css(selector, styles) {
        const element = this.getElement(selector);
        if (element) element.css(styles);
    },

    removeClass(selector, className) {
        const element = this.getElement(selector);
        if (element) element.removeClass(className);
    },

    addClass(selector, className) {
        const element = this.getElement(selector);
        if (element) element.addClass(className);
    }
};
